﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LanuageInfo.Forms.CorporaInfo
{
    public partial class FrmMain : Form
    {
       string strCorporaEasySeach = "CorporaEasySeach";
        string strCompSeach = "CompSeach ";
        string strEdit = "CorporaEdit";
        string strImp = "CorporaImp";
        string strStatistics = "CorpStatistics";

        public FrmMain()
        {
            InitializeComponent();

            if (panelCUsControl.Name != strCorporaEasySeach)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strCorporaEasySeach;
                CorporaEasyUc uc = new CorporaEasyUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barEasySeach");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strCorporaEasySeach))
            //{
            //    CorporaEasyUc uc = new CorporaEasyUc();
            //    Image image = imageList1.Images[4];
            //    ucWorkAreaMPage.AddForm(strCorporaEasySeach, "简单检索", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strCorporaEasySeach);
            //}
        }

        private void ClearFontCol(string strName)
        {
            foreach (var itm in bar1.LinksPersistInfo)
            {
                var obj = (DevExpress.XtraBars.LinkPersistInfo)itm;
                if (obj.Item.Name == strName)
                {
                    obj.Item.Enabled = false;
                }
                else
                {
                    obj.Item.Enabled = true;
                }
              
            }
        }

        private void barEasySeach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (panelCUsControl.Name != strCorporaEasySeach)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strCorporaEasySeach;
                CorporaEasyUc uc = new CorporaEasyUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barEasySeach");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strCorporaEasySeach))
            //{
            //    CorporaEasyUc uc = new CorporaEasyUc();
            //    Image image = imageList1.Images[4];
            //    ucWorkAreaMPage.AddForm(strCorporaEasySeach, "简单检索", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strCorporaEasySeach);
            //}
        }

        private void barCompSeach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (panelCUsControl.Name != strCompSeach)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strCompSeach;
                CompSeachUc uc = new CompSeachUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barCompSeach");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strCompSeach))
            //{
            //    CompSeachUc uc = new CompSeachUc();
            //    Image image = imageList1.Images[5];
            //    ucWorkAreaMPage.AddForm(strCompSeach, "复合检索", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strCompSeach);
            //}
        }

        private void barEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (panelCUsControl.Name != strEdit)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strEdit;
                CorporaEditUc uc = new CorporaEditUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barEdit");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strEdit))
            //{
            //    CorporaEditUc uc = new CorporaEditUc();
            //    Image image = imageList1.Images[6];
            //    ucWorkAreaMPage.AddForm(strEdit, "语料编辑", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strEdit);
            //}
        }

        private void barImp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (panelCUsControl.Name != strImp)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strImp;
                CorporaImpUc uc = new CorporaImpUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barImp");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strImp))
            //{
            //    CorporaImpUc uc = new CorporaImpUc();
            //    Image image = imageList1.Images[7];
            //    ucWorkAreaMPage.AddForm(strImp, "语料导入", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strImp);
            //}
        }

        private void barStatistics_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (panelCUsControl.Name != strStatistics)
            {
                panelCUsControl.Controls.Clear();
                panelCUsControl.Name = strStatistics;
                CorpStatisticsUc uc = new CorpStatisticsUc();
                uc.Dock = DockStyle.Fill;
                panelCUsControl.Controls.Add(uc);
                ClearFontCol("barStatistics");
            }
            //if (!ucWorkAreaMPage.IsTabExist(strStatistics))
            //{
            //    CorpStatisticsUc uc = new CorpStatisticsUc();
            //    Image image = imageList1.Images[8];
            //    ucWorkAreaMPage.AddForm(strStatistics, "语料统计", uc, image);
            //}
            //else
            //{
            //    ucWorkAreaMPage.ActiveTab(strStatistics);
            //}
        }
    }
}
